<template>
	<view style="background: #f1f1f1;min-height: 100vh;">
		<view class="" v-for="(item,index) in dataList" :key="index"
			style="display: flex;justify-content: space-between;align-items: center;padding: 10rpx 30rpx;margin-bottom: 10rpx;background: #fff;">
			<image :src="info.app.cdnurl+item.invited.avatar" mode="widthFix" style="width: 80rpx;height:80rpx;border-radius: 50%;">
			</image>
			<view class="">{{item.invited.nickname}}</view>
			<view class="">{{formatTimestamp(item.createtime)}}</view>
		</view>
	</view>
</template>

<script>
	import {
		getUserInviteLog
	} from "@/apis/index.js"
	export default {
		data() {
			return {
				list_rows: 20,
				page: 1,
				last_page: '',
				dataList: []
			}
		},
		onLoad() {
			this.getData()
			uni.setNavigationBarTitle({
				title: '邀请记录'
			})
		},
		computed: {
			
		},
		methods: {
			getData() {
				getUserInviteLog(this.list_rows, this.page).then(res => {
					if (res.code == 1) {
						this.last_page = res.data.last_page
						this.dataList = [...this.dataList, ...res.data.data]
					}
					console.log(res)
				})
			},
			formatTimestamp(createtime) {
				const date = new Date(parseInt(createtime) * 1000);
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, '0');
				const day = String(date.getDate()).padStart(2, '0');
				const hours = String(date.getHours()).padStart(2, '0');
				const minutes = String(date.getMinutes()).padStart(2, '0');
				const seconds = String(date.getSeconds()).padStart(2, '0');
				return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
			}
		},
		onReachBottom() {
			if (this.page < this.last_page) {
				this.page++
				this.getData()
			}
		}
	}
</script>

<style>

</style>